<!-- 
 - AdministratorHomepage.php
 - v2.0
 - 3/14/2011
 - 
 - This file presents the user interface for the administrator. 
 -->
<?php 
	session_start();
	require 'libraries/ViewAnalysisLib.php';
	require 'libraries/UserLibrary.php';
	
	isSessionSet("administrator", null, "Logout.php");	
	
	if(isset($_GET["page"]))
		$page = $_GET["page"];
	else
		$page = 1;
	
	if(isset($_POST['StatusView']))
		$status=$_POST['StatusView']; 
			
	$samplecount = CountAllSamples("casl","localhost","login","login");
?>
<html>
	<head>
		<title>CASLIMS | Administrator</title>
		<script type="text/javascript" src="scripts/validateAnalyst.js"></script>
		<link rel="stylesheet" type="text/css" href="scripts/page.css"/>
		<link href="tools/favicon.ico" rel="shortcut icon" type="image/x-icon" /> 
	</head>
	<body>
		<div id="header"></div>
		<div id="wrapper">
			<div id="pagetop">
				<div class="greeting">Hi, <?php echo $_SESSION["administrator"];?> | <a href="Logout.php">Log out</a></div>
				<div class="homepage"><?php echo $_SESSION["administrator"];?></div>				
				<form action="AdministratorHomepage.php" method="post" onsubmit="true">
				<div id="buttons">
					<input type="button" value="Add New User" onClick='document.location.href = "CreateAccount.php"' />
					<input type="button" value="Add Sample" onClick='document.location.href = "CreateSampleDetail.php"' />
					<input type="button" value="View Cost" onClick='document.location.href = "ViewAnalysisCosts.php"' />
					<select name="StatusView">
						<option value="ViewAll">View All</option>
						<option value="Ongoing">Ongoing</option>
						<option value="Endorsed">Endorsed</option>
						<option value="Finalized">Finalized</option>
					</select>					
					<input type="submit" value="View">
					<!--If previous is zero-->
					<input type="button" value="Prev Page" onClick='document.location.href = "AdministratorHomepage.php?page=<?php echo $page-1;?>"' <?php if($page-1<=0) echo "disabled=disabled"?> />
			
					<!-- -->
					<input type="button" value="Next Page" onClick='document.location.href = "AdministratorHomepage.php?page=<?php echo $page+1;?>"'  <?php if($samplecount <= ($page+1)*30) echo "disabled=disabled"?> />
				</div>
				</form>
			</div>
			
		<table id="analysisTable" border="0" width="100%">
			<thead>
				<tr>
				<th>CASL-Number</th>
				<th>Analysis Required</th>
				<th>Date Submitted</th>
				<th>Status</th>
				<th></th>
				</tr>
			</thead>
			
			<?php			
				if(!isset($status))
					DisplayAllAnalysis("casl","localhost","login","login",$page,"");		
				else{
					if($status == "ViewAll")					
						DisplayAllAnalysis("casl","localhost","login","login",$page,"");								
					else
						DisplayAllAnalysis("casl","localhost","login","login",$page,$status);
				}
			?>

		</table>
		
		<div id="footerwrap">
			<div id="footer"> 
				<div class="copyright">Copyright 2011.<a>CASL BIOTECH-UPLB.</a> All Rights Reserved.<br/> 
				Arianne Buse&ntilde;os | Darlene Joy Masong | Rick Jason Obrero | Jonathan Pandi | Jonathan Simbahan | Emmanuel Soriano 
					</div> 
    	    </div>
		</div>		
        </div>
	</body>
</html>
